package edu.bbu.license.client.android.gui.files.dialogs;

import android.app.Activity;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.widget.Button;
import edu.bbu.license.client.android.R;
import edu.bbu.license.client.android.controller.files.FilesController;

public class ServerFilePressDialogActivity extends Activity implements ServerFilePressDialogView {

	private boolean fileDeleteConfirmed = false;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_server_file_press_activity);
		
		FilesController.getInstance().atach(this);
	}

	@Override
	public void closeDialogView() {
		finish();		
	}

	@Override
	public void confirmFileDeleteRequest() {
		fileDeleteConfirmed = true;
		
		runOnUiThread(new Runnable() {
			
			@Override
			public void run() {
				String confirmationText = getString(R.string.files_activity_server_files_press_dialog_delete_confirmation_button); 
				((Button) findViewById(R.id.server_file_press_dialog_delete_button)).setText(confirmationText);
			}
		});
	}

	@Override
	public boolean isFileDeleteRequestConfirmed() {
		return fileDeleteConfirmed;
	}

	@Override
	public void setDownloadButtonListener(OnClickListener onClickListener) {
		((Button) findViewById(R.id.server_file_press_dialog_download_button)).setOnClickListener(onClickListener);
	}

	@Override
	public void setDeleteButtonListener(OnClickListener onClickListener) {
		((Button) findViewById(R.id.server_file_press_dialog_delete_button)).setOnClickListener(onClickListener);
	}

	@Override
	public void setCancelButtonListener(OnClickListener onClickListener) {
		((Button) findViewById(R.id.server_file_press_dialog_cancel_button)).setOnClickListener(onClickListener);
	}
}
